Skip to content

Add async credential concurrency control#47171

Draft
pvaneck wants to merge 1 commit into
Azure:mainfrom
pvaneck:identity-async-lock-timeout-2
Draft

Add async credential concurrency control#47171
pvaneck wants to merge 1 commit into
Azure:mainfrom
pvaneck:identity-async-lock-timeout-2

Conversation

@pvaneck
Copy link
Copy Markdown
Member

@pvaneck pvaneck commented May 27, 2026

Motivation

In high-concurrency asynchronous applications, it's common for multiple coroutines to simultaneously request an access token for the same scope (e.g., https://cosmos.azure.com/.default). When a token is expired or not yet cached, this can trigger multiple, identical, and concurrent network requests to Entra ID. This "thundering herd" can put unnecessary load on both the client app and the Entra ID service, and it can also result in redundant network calls when only one is ultimately needed.

Changes

  • Asyncio-only support for concurrency control (Trio will maintain current behavior).
  • Timeout + jitter on lock waits.

Results

  • Reduced network I/O and throttle risk in scenarios where users asynchronously create and use several clients with the same credential instance.
  • No more superfluous identical requests.
  • Independent token requests with different scopes do not block each other.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck changed the title [Identity] Add async credential concurrency control Add async credential concurrency control May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

1 participant